﻿import { isFunction } from '@/utils/is'
export const onMountedOrActivated = (hook, destroy) => {
  let mounted
  onMounted(() => {
    hook()
    nextTick(() => {
      mounted = true
    })
  })
  onActivated(() => {
    if (mounted) {
      hook()
    }
  })
  onBeforeUnmount(() => {
    if (isFunction(destroy)) {
      destroy()
    }
  })

  onDeactivated(() => {
    if (isFunction(destroy)) {
      destroy()
    }
  })
}
